//@ts-nocheck
// const CryptoJS = require('crypto-js')

import CryptoJS from "crypto-js"

export function transPwdMD5(old: string) {
  var next = 'bm' + old + '.*'
  return CryptoJS.MD5(next).toString()
}

// md5 加盐
export function md5ValueSalt(value :string, salt: string) {
  var next = `${value}${salt}`
  return CryptoJS.MD5(next).toString()
}

export function encryptMsg(text :string, key :string) {
  // console.log(`加密key: ${key}`)
  // console.log(`加密数据: ${text}`)

  var encryptText = CryptoJS.AES.encrypt(text, key)

  var encryptValue = encryptText.toString()

  // console.log(`加密后数据：${encryptValue}`)

  return encryptValue
}

export function decryptMsg(text :string, key :string) {
  // console.log(`解密key: ${key}`)
  // console.log(`解密前数据: ${text}`)

  var decryptText = CryptoJS.AES.decrypt(text, key)
  // console.log(decryptText)

  const value = decryptText.toString(CryptoJS.enc.Utf8)
  // console.log(`解密后数据：${value}`)

  return value
}


window.encryptMsg = encryptMsg

window.decryptMsg = decryptMsg